package com.chen.common.mbg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.common.dto.goodsParam;
import com.chen.common.mbg.pojo.Goods;
import com.chen.common.mbg.service.GoodsService;
import com.chen.common.mbg.mapper.GoodsMapper;
import com.chen.common.utils.BeanUtil;
import com.chen.common.vo.goodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Chen'SH
* @description 针对表【ak_goods】的数据库操作Service实现
* @createDate 2022-06-28 12:10:25
*/
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods>
    implements GoodsService{

    @Autowired
    private GoodsMapper goodsMapper;


    /**
     * 文章查询及分类查询
     * @param po
     * @return
     */
    @Override
    public List<goodsVo> listAll(goodsParam po) {
        Page<Goods> page = new Page<>(po.getPageNum(),po.getPageSize());
        Page<Goods> newPage = goodsMapper.selectPage(page, new LambdaQueryWrapper<Goods>().like(Goods::getGCategory,po.getGCategory())
                .like(Goods::getGName,po.getGName()));
        List<Goods> records = newPage.getRecords();
        List<goodsVo> goodsVos = BeanUtil.listA2ListB(records, goodsVo.class);
        return goodsVos;
    }
}




